package dyyx;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import dyyx.data.Data;

// import com.netflix.appinfo.InstanceInfo;
// import com.netflix.discovery.DiscoveryClient;

@RestController
//@Scope("prototype")
public class FeginHelloController {
	
	
	@Autowired
    private FeginHello feginHello; 
	
	
	@RequestMapping(value = "/fegin/hello")
    public Map<String,Object> hello(@RequestBody  Data data) throws Exception {
		Map<String,Object> map = new HashMap<>();
    	map.put("input",data);
		long start = System.currentTimeMillis();
    	Data result = feginHello.hello(data);
    	map.put("result",result);
    	long end = System.currentTimeMillis();
		long time = end - start;
		map.put("time", time);

    	return map; 	
    }
	
	@RequestMapping(value = "/fegin/hello2")
    public Map<String,Object> hello2(@RequestParam("name")  String name) throws Exception {
		Map<String,Object> map = new HashMap<>();
		long start = System.currentTimeMillis();
    	String result = feginHello.hello2(name);
		long end = System.currentTimeMillis();
		long time = end - start;
		map.put("result", result);
		map.put("time", time);

    	return map; 	
    }
	
	@RequestMapping(value = "/fegin/hello3")
    public Map<String,Object> hello3(@RequestParam("name")  String name) throws Exception {
		Map<String,Object> map = new HashMap<>();
		long start = System.currentTimeMillis();
		// use post
    	String result = feginHello.hello3(name);
		long end = System.currentTimeMillis();
		long time = end - start;
		map.put("result", result);
		map.put("time", time);

    	return map; 	
    }
    
	
	
    
}